<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>求和</title>
	<style type = "text/css">
    #box{
           margin: 0 auto;
           width: 300px;
    }
	</style>
	<script type = "text/javascript">
		window.onload = function () {
		    var Obtn =document.getElementById('btn');
		    Obtn.onclick = function(){
		    	var OVa = document.getElementById("value");
		    	 		    	// alert(OVa.value)
		        // console.log(typeof OVa.value)
		        
                var strArr = OVa.value.split(',')
                // alert(strArr.length);
                   var totalNum = 0;
                for (var i = 0; i < strArr.length; i++) {
                	totalNum += parseInt(strArr[i]);
                }	
                alert(totalNum)	     
		    }
		}
	</script>
</head>
<body>
	<div id="box">
		<input type="text" value="1,2,3,4,5" id="value">
		<br>
		<input type="button" id="btn" value="求和">
	</div>
</body>
</html>
